/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package pe.com;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
//import org.hibernate.StatelessSession;

/**
 *
 * @author romulogalindo
 */
public class ColaUnidadesSinProcesar {

    private static LinkedBlockingQueue<Object> tasks = null;
    private boolean alive = true;

    static {
        tasks = new LinkedBlockingQueue<>();
    }

    public static void nuevaUnidad(Object task) {
        tasks.add(task);
    }

    public static Object consumirUnidad() throws InterruptedException {
        return tasks.take();
    }
    
    public static Object consumirUnidad2() throws InterruptedException {
        return tasks.poll(5, TimeUnit.SECONDS);
    }

    public static boolean isEmpty() {
        return tasks.isEmpty();
    }

    public static int taskssize() {
        return tasks.size();
    }
}
